//414. 第三大的数

#include <stdlib.h>
int cmp_int(const void* p1, const void* p2)
{
    return *(int*)p1 < *(int*)p2;
}
int thirdMax(int* nums, int numsSize) {
    //1.先排降序
    //2.遍历
    qsort(nums, numsSize, sizeof(int), cmp_int);
    int count = 1;
    for (int i = 0; i < numsSize - 1; i++)
    {
        if (nums[i] != nums[i + 1])
            count++;
        if (3 == count)
            return nums[i + 1];
    }
    return nums[0];
}